var appApi = (function () {

    /** @namespace */
    var appApi = {

        /**
         * appApi被初始化完成事件，当初始化完成后appApi的方法才可用！！
         * @param {function} callback - 回调
         */
        onLoaded: function (callback) {
        },


        /**
         * 点击状态栏事件，当初始化完成后appApi的方法才可用！！
         * @param {function} callback - 回调
         */
        onStatusBar: function (callback) {
        },

        /**
         * @callback getToKenCallback
         * @param {string} error
         * @param {string} toKen - 结果.
         */

        /**
         * appApi被初始化完成事件，当初始化完成后appApi的方法才可用！！
         * @param {getToKenCallback} callback - 回调
         */
        getToken: function (callback) {

        },

        /**
         * 唤起地图
         * @param {string} url
         * @param {string} type 1:固定加载HTML 2:动态可拉动下拉框
         */
        showMap: function (url, type, height, callback,backData) {

        },
        //lyy
        //@param {string} geometry
        deviceNav:function(geometry,callback){

        },
        /*
         *重新加载一个新webview页面
         * @param {string} url
         * @param (pushToNewWebviewCallback) callback
         */

        pushToNewWebview: function (url, callback) {


        },

        /*
         *给页面弹出一个toast提示
         *@param {string} title;
         *@param (tosatAtIphoneCallback) callback
         */

        tosatAtIphone: function (title, callback) {


        },

        map: {
            /**
             * @typedef mapSiteData
             * @type {object}
             * @property {number} longitude - 经度.
             * @property {number} latitude - 纬度.
             * @property {string} name - poi或设备名称.
             * @property {string} id - 设备id
             * @property {string} type - 设备类型ID
             * @property {string} address - 格式化地址，如：北京市朝阳区南磨房镇北京国家广告产业园区
             * @property {string} province - 省份，如：北京市
             * @property {string} city - 城市，直辖市会返回空
             * @property {string} district - 行政区，如：朝阳区
             * @property {string} road - 街道，如：西大望路甲12-2号楼
             */

            /**
             * @typedef mapTapEventData
             * @type {object}
             * @property {number} longitude - 经度.
             * @property {number} latitude - 纬度.
             * @property {object} userData - 自定义数据
             */

            /**
             * @callback mapTapEventcallback
             * @param {string} error
             * @param {mapTapEventData|mapSiteData} data - 结果.
             */

            /**
             * 地图单机击事件
             * @param {mapTapEventcallback} callback - 回调
             */
            onMapTapEvent: function (callback) {

            },


            /**
             * @callback getMapMarkcallback
             * @param {string} error
             * @param {mark[]} data
             */

            /**
             * 获取地图中的点
             * @param {getMapMarkcallback} callback - 回调
             */
            getMapMark: function (callback) {

            },


            /**
             * @callback getMapLinecallback
             * @param {string} error
             * @param {mark[]} data
             */

            /**
             * 获取地图中的点
             * @param {getMapLinecallback} callback - 回调
             */
            getMapLine: function (callback) {

            },


            /**
             * @typedef mark
             * @type {object}
             * @property {string} id
             * @property {GeoJson} geoJson - geojso的几何体.
             * @property {string} color - 颜色.  -'rgba(255,0,0,1)'
             * @property {string} selectColor - 选中颜色.
             * @property {string} image - 图片url
             * @property {string} selectImage - 选中图片url
             * @property {object} userData - 自定义数据.
             */

            /**
             * @typedef addMarkCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             * 地图标注点(传一个点可实现定位功能) 有修改
             * @param {mark[]} data
             * @param {addMarkCallback} callback
             */
            addMark: function (data, callback) {
            },


            /**
             * @typedef mark
             * @type {object}
             * @property {string} id
             * @property {GeoJson} geoJson - geojso的几何体.
             * @property {string} color - 颜色.  -'rgba(255,0,0,1)'
             * @property {string} selectColor - 选中颜色.
             * @property {string} image - 图片url
             * @property {string} selectImage - 选中图片url
             * @property {object} userData - 自定义数据.
             */

            /**
             * @typedef addLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             * 地图标注线
             * @param {mark[]} data
             * @param {addLineCallback} callback
             */
            addLine: function (data, callback) {

            },


            /**
             * @typedef mapSiteSelectionCallback
             * @param {string} error
             * @param {mapSiteData} data - 结果.
             */

            /**
             * 地图选址
             * @param {mapSiteSelectionCallback} callback
             */
            mapSiteSelection: function (callback) {
            },


            /**
             * @typedef selectMarkCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *设置选中标注点
             * @param {string} id
             * @param {selectMarkCallback} callback
             */
            selectMark: function (id, callback) {

            },


            /**
             * @typedef selectLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *设置选中标注线
             * @param {string} id
             * @param {selectLineCallback} callback
             */
            selectLine: function (id, callback) {

            },


            /**
             * @typedef removeSelectMarkCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *移除选中标注点
             * @param {string} id
             * @param {removeSelectMarkCallback} callback
             */
            removeSelectMark: function (id, callback) {

            },


            /**
             * @typedef removeSelectLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *移除选中标注线
             * @param {string} id
             * @param {removeSelectLineCallback} callback
             */
            removeSelectLine: function (id, callback) {

            },


            /**
             * @typedef removeAllMarkCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *全部移除标注点
             * @param {removeAllMarkCallback} callback
             */
            removeAllMark: function (callback) {

            },


            /**
             * @typedef removeAllLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */
            /**
             *全部移除标注点
             * @param {removeAllLineCallback} callback
             */
            removeAllLine: function (callback) {
            },


            /**
             * @typedef removeIdsMarkCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             * 移除ids数组中的标注点
             * @param {string[]} ids
             * @param {removeIdsMarkCallback} callback
             */
            removeIdsMark: function (ids, callback) {

            },


            /**
             * @typedef removeIdsLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             * 移除ids数组中的标注线
             * @param {string[]} ids
             * @param {removeIdsLineCallback} callback
             */
            removeIdsLine: function (ids, callback) {

            },


            /**
             * 可视区域定位
             * @param {number} maxLongitude - 最大经度.
             * @param {number} maxLatitude - 最大纬度.
             * @param {number} minLongitude - 最小经度.
             * @param {number} minLatitude - 最小纬度.
             */
            visualAreaLocation: function (maxLongitude, maxLatitude, minLongitude, minLatitude) {

            },


            /*
             用于js端通知oc已经拖动到顶部的事件 2016-11-17

             */


            scrollTopNotify: function (callback) {

            },

            /**
             * @typedef bubbleData
             * @type {object}
             * @property {string} id -该气泡窗的id
             * @property {number} longitude - 经度.
             * @property {number} latitude - 纬度.
             * @property {string} content -要展示文字的内容
             * @property {string} textColor - 颜色.  -'rgba(255,0,0,1)' 默认rgba(51,51,51,1)黑色
             * @property {number} font - 字体大小
             * @property [number,number] point --设置视图的锚点(默认不设置锚点位(0.5,1))
             * @property {string} imageUrl  --传来图片的全路径
             *
             */

            /**
             * @typedef addBubbleCallback
             * @param {bool} b -成功或失败.
             * @param {string} error
             */

            /**
             * 地图标注点(传一个点可实现定位功能) 有修改
             * @param {bubbleData[]} data
             * @param {addBubbleCallback} callback
             * @param {string}type -气泡的类型("text"带文字默认气泡,'image'展示图片气泡)
             */
            addBubble: function (type, data, callback) {

            },


            /**
             * @typedef removeAllBubbleCallback
             * @param {bool} b -成功或失败.
             */

            /**
             *全部移除标注点
             * @param {removeAllBubbleCallback} callback
             */
            removeAllBubble: function (callback) {

            },


            /**
             * @typedef removeSelectBubbleCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *移除选中标注点
             * @param {string} id
             * @param {removeSelectBubbleCallback} callback
             */
            removeSelectBubble: function (id, callback) {

            },

            /**
             用于js端给oc端传入巡视路线界面网页高度
             * @typedef giveWebviewHeightCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *移除选中标注点
             * @param {string} height
             * @param {giveWebviewHeightCallback} callback
             */

            giveWebviewHeight: function (height, callback) {

            },
            /**
             * @typedef selectIdsLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *设置选中标注线
             * @param {string[]} ids
             * @param {selectIdsLineCallback} callback
             */
            selectIdsLine: function (ids, callback) {

            },


            /**
             * @typedef removeSelectIdsLineCallback
             * @param {string} error
             * @param {bool} b -成功或失败.
             */

            /**
             *设置选中标注线
             * @param {string[]} ids
             * @param {sremoveSelectIdsLineCallback} callback
             */
            removeSelectIdsLine:function(ids,callback){


            },
            /**
             * @typedef noticeChangeOffsetCallback
             *@param {string} state

             *state = 'startAtBottom' //刚开始在底部拖动
             *state = 'startAtMiddle' //刚开始拖动在中部
             *state = 'finishedStopBottom' //拖动完成后在底部
             *state = 'finishedStopMiddle' //拖动完成后在中部
             */

            noticeChangeOffset:function(callback){

            },


            /**
             * @typedef changeToolBarStateCallback
             * @param {string} error 或者 success

             */
            changeToolBarState:function(title,callback){


            }


        },

        /** @namespace */
        device: {

            /**
             * 这个回调被  appApi.device.getNetworkType 方法使用
             * @callback getNetworkTypeCallback
             * @param {string} error
             * @param {string} data - wifi、2g、3g、4g、unknown、none，none表示离线
             */

            /**
             * 获取当前网络类型
             * @param {getNetworkTypeCallback} callback - 回调
             */
            getNetworkType: function (callback) {
            },

            /**
             *这个回调被  appApi.device.getImage 方法使用
             * @callback getImageCallback
             * @param {string} error
             * @param {string} data - 为base64编码的图片流
             */

            /**
             * 获取图片
             * @param {getImageCallback} callback - 回调
             */
            getImage: function (callback) {
            },
            /**
             这个回掉被 appApi.device.getMovie 方法使用
             *@callback getMovieCallback
             *@param {string} error
             *@param {string} data  -为base64编码的视频流
             */

            /**
             *获取图片
             *@param {getMovieCallback} callback - 回调
             *
             */


            getMovie: function (callback) {


            },


            /**
             这个回调被 appApi.device.alterAudioRecorder
             @callback alterAudioRecorderCallback
             @param {string} error
             @param {string} data  -为base64编码的音频流
             @param {string} time  -时长

             */
            /**
             *@param {alterAudioRecorder} callback - 回调
             *@example
             * data = {
             *      height:200
             * }

             */

            alterAudioRecorder: function (data,callback) {


            },
            setAudioSession: function (callback) {
            },

            /** @namespace */
            audio: {

                /**
                 *这个回调被  appApi.device.audio.startRecord 方法使用
                 * @callback startRecordCallback
                 * @param {string} error
                 */

                /**
                 * 开始录音,启动语音录制，支持最长为60秒（包括）的音频录制。
                 * @param {startRecordCallback} callback - 回调
                 */
                startRecord: function (callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.stopRecord 方法使用
                 * @callback stopRecordCallback
                 * @param {string} error
                 */

                /**
                 * 停止语音录制
                 * @param {stopRecordCallback} callback - 回调
                 */
                stopRecord: function (callback) {
                },

                /**
                 * @typedef onRecordEndCallbackData
                 * @type {object}
                 * @property {string} audioID - 音频唯一id.
                 * @property {number} time - 音频的时长，单位：秒.
                 */

                /**
                 *这个回调被  appApi.device.audio.onRecordEnd 方法使用
                 * @callback onRecordEndCallback
                 * @param {string} error
                 * @param {onRecordEndCallbackData} data
                 */

                /**
                 * 监听录音停止,当录音60秒或调用stopRecord时，onRecordEnd被调用
                 * @param {onRecordEndCallback} callback - 回调
                 */
                onRecordEnd: function (callback) {
                },

                /**
                 * @typedef getRecordCallbackData
                 * @type {object}
                 * @property {string} audioID - 音频唯一id.
                 * @property {number} time - 音频的时长，单位：秒.
                 * @property {string} buffer - base64音频流.
                 */

                /**
                 *这个回调被  appApi.device.audio.getRecord 方法使用
                 * @callback getRecordCallback
                 * @param {string} error
                 * @param {getRecordCallbackData} data
                 */

                /**
                 * 获取音频流
                 * @param {string} audioID - 音频唯一id
                 * @param {getRecordCallback} callback - 回调
                 */
                getRecord: function (audioID, callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.play 方法使用
                 * @callback playCallback
                 * @param {string} error
                 */

                /**
                 * 播放语音
                 * @param {string} audioID - 音频唯一id
                 * @param {playCallback} callback  - 回调
                 */
                play: function (audioID, callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.pause 方法使用
                 * @callback pauseCallback
                 * @param {string} error
                 */
                /**
                 * 暂停播放语音
                 * @param {string} audioID - 音频唯一id
                 * @param {pauseCallback} callback - 回调
                 */
                pause: function (audioID, callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.resume 方法使用
                 * @callback resumeCallback
                 * @param {string} error
                 */
                /**
                 * 恢复暂停播放的语音
                 * @param {string} audioID - 音频唯一id
                 * @param {resumeCallback} callback - 回调
                 */
                resume: function (audioID, callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.stop 方法使用
                 * @callback stopCallback
                 * @param {string} error
                 */
                /**
                 * 停止播放语音
                 * @param {string} audioID - 音频唯一id
                 * @param {stopCallback} callback - 回调
                 */
                stop: function (audioID, callback) {
                },

                /**
                 *这个回调被  appApi.device.audio.onPlayEnd 方法使用
                 * @callback onPlayEndCallback
                 * @param {string} error
                 * @param {string} audioID - 音频流ID.
                 */
                /**
                 * 监听播放自动停止,语音播放完毕时自动调用该方法设置的回调，并返回音频流ID
                 * @param {function} callback - 回调
                 */
                onPlayEnd: function (onPlayEndCallback) {
                },
            },

            /**
             *这个回调被  appApi.device.scanCode 方法使用
             * @callback onScanCodeCallback
             * @param {string} error
             * @param {string} data - 扫描结果
             */
            /**
             * 扫码并返回结果
             * @param {function} callback - 回调
             */
            scanCode: function (Callback) {
            }
        },


        /**
         * @typedef getLocationCallbackData
         * @type {object}
         * @property {number} longitude - 经度.
         * @property {number} latitude - 纬度.
         * @property {number} accuracy - 实际的定位精度半径（单位米）.
         */

        /**
         *这个回调被  appApi.getLocation 方法使用
         * @callback getLocationCallback
         * @param {string} error
         * @param {getLocationCallbackData} data - 结果.
         */
        /**
         * 获取当前地理位置
         * @param {number} targetAccuracy - 期望定位精度半径（单位米），定位结果尽量满足该参数要求，但是不一定能保证小于该误差，开发者需要读取返回结果的 accuracy 字段校验坐标精度
         * @param {getLocationCallback} callback - 回调
         */
        getLocation: function (targetAccuracy, callback) {
        },

        /**
         *这个回调被  appApi.showNavigation 方法使用
         * @callback showNavigationCallback
         * @param {string} error
         */
        /**
         * 唤起导航页面
         * @param {object} data
         * @param {string } name - 目的地位置名称
         * @param {target[]}  target - 目的地位置坐标数组[longitude, latitude]
         * @param {function} callback - 回调
         * @example
         * {
         *      name:'名字',
         *      target:[123.445,23.0354]
         * }
         */
        showNavigation: function (data, callback) {
        },

        /**
         *这个回调被  appApi.showUserInfo 方法使用
         * @callback showUserInfoCallback
         * @param {string} error
         */
        /**
         * 唤起用户资料页面
         * @param {string} userID - 用户id
         * @param {function} callback - 回调
         */
        showUserInfo: function (userID, callback) {
        },

        /**
         *这个回调被  appApi.showIm 方法使用
         * @callback showImCallback
         * @param {string} error
         */
        /**
         * 唤起聊天页面
         * @param {string} targetID - 用户id或群组ID
         * @param {function} callback - 回调
         */
        showIm: function (targetID, callback) {
        },

        /**
         * @typedef choosUsersParameters
         * @type {object}
         * @property {number} startWithDepartmentId - 1表示从自己所在部门开始, 0表示从企业最上层开始,默认为0.
         * @property {boolean} multiple - 是否多选,默认true.
         * @property {boolean} onlyUser - 是否支持选择部门.
         */

        /**
         * @typedef choosUsersCallbackData
         * @type {object}
         * @property {user[]} users - 选择的人员
         * @property {string[]} groups - 选择的部门
         * @example
         * {
         *   'users':[
         *       {
         *           'userID': '0573',
         *           'IMID': '0573',
         *           'name': '张三',
         *           'image': "url",
         *           'parent':'研发一部'
         *       }
         *   ],
         *   'groups':[
         *       'name1','name2'
         *   ]
         * }
         */
        /**
         *这个回调被  appApi.choosUsers 方法使用
         * @callback choosUsersCallback
         * @param {string} error
         * @param {choosUsersCallbackData} data
         */

        /**
         * 选人/选部门
         * @param {choosUsersParameters} parameters
         * @param {choosUsersCallback} callback - 回调
         */
        choosUsers: function (parameters, callback) {
        },

        /**
         *这个回调被  appApi.sendMessage 方法使用
         * @callback sendMessageCallback
         * @param {string} error
         */
        /**
         * 发消息
         * @param {string | string[]} targets - userID，array userID数组，string groupID '
         * @param {boolean} isGroupTaraget - 是否 groupID
         * @param {object} msg - msg的json对象
         * @param {sendMessageCallback} callback - 回调
         */
        sendMessage: function (targets, isGroupTaraget, msg, callback) {
        },


        /**
         *这个回调被  appApi.alterAndSendMessage 方法使用
         * @callback alterAndSendMessageCallback
         * @param {string} error
         */
        /**
         * 发消息

         * @param {object} msg - msg的json对象
         * @param {alterAndSendMessageCallback} callback - 回调
         */

        alterAndSendMessage: function (msg, callback) {

        },

        /**
         * @param {mapSiteData} mapSiteData 传给oc端mapSiteData类型数据用于收藏
         * @param {function} callback - 回调
         */
        collectPOI: function (mapSiteData, callback) {

        },


        /*
         *取消收藏
         * @param {mapSiteData} mapSiteData 传给oc端mapSiteData类型数据用于收藏
         * @param {function} callback - 回调

         */
        cancelCollectPOI: function (mapSiteData, callback) {


        },

        /** @namespace */
        ui: {
            /** @namespace */
            navigation: {
                /**
                 *这个回调被  appApi.ui.navigation.setColor 方法使用
                 * @callback setColorsCallback
                 * @param {string} error
                 */
                /**
                 * 设置导航栏颜色
                 * @param {string} color - 'rgb(255,0,0)'或者是int值
                 * @param {setColorsCallback} callback - 回调
                 */
                setColor: function (color, callback) {
                },

                /**
                 *这个回调被  appApi.ui.navigation.setTitle 方法使用
                 * @callback setTitleCallback
                 * @param {string} error
                 */
                /**
                 * 设置导航栏标题
                 * @param {string} titel - 标题
                 * @param {setTitleCallback} callback - 回调
                 */
                setTitle: function (title, callback) {
                },

                /**
                 *这个回调被  appApi.ui.navigation.onRollbackButtonClick 方法使用
                 * @callback onRollbackButtonClickCallback
                 */
                /**
                 * 当点击导航栏回退按钮时触发
                 * @param {onRollbackButtonClickCallback} callback - 回调
                 */
                onRollbackButtonClick: function (callback) {
                },

                /**
                 * 触发关闭
                 * @param {object} data -
                 * @param {function} callback - 回调
                 */
                close: function (data,callback) {
                },

                /**
                 * 添加关闭按钮
                 isHidden 为bool类型值
                 * @param {function} callback - 回调
                 */

                addCloseButton: function (isHidden, callback) {

                },

                /**
                 * @typedef menuStyle
                 * @type {object}
                 * @property {string} backgroundColor - 背景色 '颜色 rgba(0,0,0) 1212 #ffffff'
                 * @property {item[]} items - 菜单项数组
                 * @example
                 * {
				 * 	'backgroundColor':'rgba(255,255,0,255)',
				 * 	'items':[
				 * 		{
				 * 			'icon':'icon的url',
				 * 			'text':'文字,必填项',
				 * 			'type': '在一个应用下唯一,必填项'
				 * 			'onClick':function(){}
				 * 		}
				 * 	 ]
				 * 	 }
                 * }
                 *  */

                /**
                 * 设置导航栏右侧按钮
                 * @param {menuStyle} menuStyle - 右侧按钮样式
                 * @param {function} callback - 回调
                 */
                setMenu: function (menuStyle, callback) {
                }
            }
        }
    }
    var ua = navigator.userAgent.toLowerCase();
    //IOS
    if (/iphone|ipad|ipod/.test(ua)) {
        function setupWebViewJavascriptBridge(callback) {

            if (window.WebViewJavascriptBridge) {
                return callback(WebViewJavascriptBridge);
            }
            if (window.WVJBCallbacks) {
                return window.WVJBCallbacks.push(callback);
            }
            window.WVJBCallbacks = [callback];
            var WVJBIframe = document.createElement('iframe');
            WVJBIframe.style.display = 'none';
            WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
            document.documentElement.appendChild(WVJBIframe);
            setTimeout(function () {
                document.documentElement.removeChild(WVJBIframe);
            }, 0)
        }

        var zwiosobj = function (bridge) {
            var uniqueId = 1

            function log(message, data) {
                var log = document.getElementById('log')
                var el = document.createElement('div')
                el.className = 'logLine'
                el.innerHTML = uniqueId++ + '. ' + message + ':<br/>' + JSON.stringify(data)
                if (log.children.length) {
                    log.insertBefore(el, log.children[0])
                } else {
                    log.appendChild(el)
                }
            }

            appApi.ui.navigation.setTitle = function (title, callback) {
                bridge.callHandler('TheNavBarTitleChange', title, function (responseData) {
                    callback(responseData);

                })
            }

            appApi.ui.navigation.setColor = function (color, callback) {

                bridge.callHandler('TheNavBarColorChange', color, function (responseData) {
                    callback(responseData);

                })
            }

            appApi.ui.navigation.close = function (data,callback) {

                bridge.callHandler('CloseTheNavBarAction',data, function (responseData) {

                    callback(responseData);


                })
            }

            appApi.ui.navigation.setMenu = function (parameters, callback) {

                bridge.callHandler('TheNavBarRightButtonSet', parameters, function (responseData) {
                    for (var i = 0; i < parameters.items.length; i++) {
                        if (parameters.items[i].type == responseData) {
                            parameters.items[i].onClick();
                        }
                    }
                    callback(responseData);
                    aaaa;
                })

            }

            appApi.device.getNetworkType = function (callback) {


                bridge.callHandler('getTheAppNetType', function (responseData) {

                    callback(responseData);

                })

            }

            // ��������ҳ��
            appApi.showIm = function (userID, callback) {

                bridge.callHandler('EnterTheChatVC', userID, function (responseData) {

                    callback(responseData);

                })


            };

            appApi.showUserInfo = function (userID, callback) {

                bridge.callHandler('EnterTheUserInformationVC', userID, function (responseData) {

                    callback(responseData);

                })
            };

            //������Ϣ
            appApi.sendMessage = function (targets, isGroupTaraget, msg, callback) {
                msg.users = targets;
                msg.isGroupTaraget = isGroupTaraget;

                bridge.callHandler('sendMessageAction', msg, function (responseData) {

                    callback(responseData);

                })


            }

            appApi.alterAndSendMessage = function (msg, callback) {

                bridge.callHandler('alterAndSendMessage', msg, function (responseData) {


                    callback(responseData);

                })

            }

            appApi.choosUsers = function (parameters, callback) {

                bridge.callHandler('ModelTheCommonUser', parameters, function (responseData) {

                    callback(responseData);

                })

            }

            // ��ȡ����ͼƬ
            appApi.device.getImage = function (callback) {


                bridge.callHandler('getThePhotoFromPhone', function (responseData) {

                    callback(responseData.error, responseData.data, responseData.type);

                })


            }


            appApi.device.getMovie = function (callback) {

                bridge.callHandler('ocjs_takeTheMoviewFromPhone', function (responseData) {


                    callback(responseData.error, responseData.data);


                })


            };


            appApi.device.alterAudioRecorder = function (data,callback) {

                bridge.callHandler('ocjs_alterAudioRecorder', data,function (responseData) {


                    callback(responseData.error, responseData.data, responseData.time, responseData.audioSize);


                })


            }


            appApi.device.setAudioSession = function (callback) {

                bridge.callHandler('ocjs_setAudioSession', function (responseData) {


                    callback();

                })

            }

            appApi.getLocation = function (targetAccuracy, callback) {

                bridge.callHandler('GetThePresentLocaltion', targetAccuracy, function (responseData) {

                    callback(responseData);

                });
            };

            appApi.showMap = function (url, type, height, callback,backData) {

                var param = {'url': url, 'type': type, 'height': height};

                bridge.callHandler('EnterTheAddMarkVCWithType', param, function (responseData) {

                    callback(responseData);

                });
                bridge.callHandler('EnterTheAddMarkVCWithBackData', param, function (responseData) {

                    backData(responseData);

                });
            }
            //lyy---------------------
            /* appApi.deviceNav = function(geometry,callback){
                bridge.callHandler('SetTheGeometry', geometry, function (responseData) {
                    callback(responseData);
                });
            } */
            //lyy---------------------

            appApi.device.audio.startRecord = function (callback) {

                bridge.callHandler('startRecordTheAudio', function (responseData) {

                    callback(responseData);

                });
            }

            appApi.device.audio.stopRecord = function (callback) {

                bridge.callHandler('stopRecordAudio', function (responseData) {

                    callback(responseData);

                });
            }

            appApi.device.audio.onRecordEnd = function (callback) {   //oc��������js

                bridge.registerHandler("whenTheRecordAudioStoped", function (data, responseCallback) {
                    responseCallback()
                });
            }

            appApi.device.audio.getRecord = function (audioID, callback) {

                bridge.callHandler('getTheAudioFromTheOCApp', audioID, function (responseData) {

                    callback(responseData);

                });
            }

            appApi.device.audio.play = function (audioID, callback) {

                bridge.callHandler('playTheAudio', audioID, function (responseData) {

                    callback(responseData);

                });
            }

            appApi.device.audio.pause = function (audioID, callback) {

                bridge.callHandler('pauseTheAudio', audioID, function (responseData) {

                    callback(responseData);

                });

            }

            appApi.device.audio.resume = function (audioID, callback) {

                bridge.callHandler('resumeTheAudio', audioID, function (responseData) {

                    callback(responseData);

                });
            }

            appApi.device.audio.stop = function (audioID, callback) {

                bridge.callHandler('stopPlayTheAudio', audioID, function (responseData) {
                    callback(responseData);

                });

            }

            appApi.device.audio.onPlayEnd = function (callback) {

                bridge.registerHandler("whenTheRecordAudioStoped", function (data, responseCallback) {
                    responseCallback();

                });
            }

            //// ����·����������
            appApi.showNavigation = function (data, callback) {

                //var param = {'start': name, 'target': target};

                bridge.callHandler('showPathProgramme', data, function (responseData) {
                    callback(responseData);
                });
            }

            appApi.setMenu = function (menuStyle, callback) {

                bridge.registerHandler("ocToJsMenuClick", function (data, responseCallback) {

                    for (var i = 0; i < menuStyle.items.length; i++) {
                        if (menuStyle.items[i].type == data.type) {
                            (menuStyle.items[i].onClick());
                        }
                    }

                });

                //for(var i =0; i < menuStyle.items.length; i++){
                //	(
                //	var f = i;
                //	bridge.registerHandler(menuStyle.items[f].text, function (data, responseCallback) {
                //		menuStyle.items[f].onclick();
                //	}))();
                //}
            }

            //��ͼ�����¼�
            appApi.map.onMapTapEvent = function (callback) {

                bridge.registerHandler('whenUserTapTheMap', function (data, responseCallback) {

                    callback(data.error, data.data);

                })


            }


            appApi.map.scrollTopNotify = function (callback) {

                bridge.callHandler('ocjs_scrollTopNotify', function (responseData) {

                    callback();

                });


            }


            appApi.map.addMark = function (data, callback) {

                //var param = {'url': url, 'data': data};

                bridge.callHandler('ocjs_addMarkToTheMap', data, function (responseData) {

                    callback(responseData.error, responseData.b);
                })
            }


            //addLine
            appApi.map.addLine = function (data, callback) {

                bridge.callHandler('ocjs_addLinesToTheMap', data, function (responseData) {

                    callback(responseData.error, responseData.b);

                })
            }


            appApi.map.removeIdsMark = function (ids, callback) {

                bridge.callHandler('removeIdsMark', ids, function (responseData) {

                    callback(responseData.error, responseData.b);

                })

            }

            //removeIdsLine
            appApi.map.removeIdsLine = function (ids, callback) {

                bridge.callHandler('ocjs_removeIdsline', ids, function (responseData) {

                    callback(responseData.error, responseData.b);

                })

            }


            appApi.map.visualAreaLocation = function (maxLongitude, maxLatitude, minLongitude, minLatitude) {

                var param = {
                    'maxLong': maxLongitude,
                    'maxLat': maxLatitude,
                    'minLong': minLongitude,
                    'minLat': minLatitude
                };

                bridge.callHandler('ocjs_visualAreaLocation', param, function (responseData) {


                })


            }


            appApi.map.mapSiteSelection = function (callback) {

                bridge.callHandler('selectFromTheMap', function (responseData) {

                    callback(responseData.error, responseData.data);

                })

            }

            appApi.map.removeAllMark = function (callback) {

                bridge.callHandler('removeAllMark', function (responseData) {

                    callback(responseData.error, responseData.data);

                })


            }

            //removeAllLine
            appApi.map.removeAllLine = function (callback) {

                bridge.callHandler('ocjs_removeAlllines', function (responseData) {

                    callback(responseData.error, responseData.data);

                })


            }


            appApi.map.removeSelectMark = function (id, callback) {

                bridge.callHandler('ocjs_removeSelectMark', id, function (responseData) {

                    callback(responseData.error, responseData.b);

                })


            }

            appApi.map.selectIdsLine = function (ids, callback) {

                bridge.callHandler('ocjs_lightIdsLineHightLight',ids,function(responseData){


                    callback(responseData.error,responseData.b);


                })

            }


            appApi.map.removeSelectIdsLine = function(ids,callback){


                bridge.callHandler('ocjs_removeIdslineHightLight',ids,function(responseData){


                    callback(responseData.error,responseData.b);

                })


            }

            appApi.map.noticeChangeOffset = function(callback){

                bridge.registerHandler('ocjs_noticeChangeOffset',function(data, responseCallback){

                    callback(data)

                })


            }

            appApi.map.changeToolBarState = function(title,callback){

                bridge.callHandler('ocjs_changeToolBarState',title,function(responseData){


                    callback(responseData);


                })



            }


            appApi.map.removeSelectLine = function (id, callback) {

                bridge.callHandler('ocjs_removeSelectLine', id, function (responseData) {

                    callback(responseData.error, responseData.b);

                })


            }

            appApi.map.addBubble = function (type, data, callback) {


                var param = {'type': type, 'data': data};

                bridge.callHandler('ocjs_addBubbleView', param, function (responseData) {

                    callback(responseData.b, responseData.error);

                })

            }
            appApi.map.removeAllBubble = function (callback) {

                bridge.callHandler('ocjs_removeAllBubble', function (responseData) {

                    callback(responseData.b)

                })


            }

            appApi.map.removeSelectBubble = function (id, callback) {

                bridge.callHandler('ocjs_removeSelectBubble', id, function (responseData) {


                    callback(responseData.error, responseData.b);


                })

            }

            appApi.map.giveWebviewHeight = function (height, callback) {

                bridge.callHandler('ocjs_AMDCtrlOffsetHeight', height, function (responseData) {


                    callback(responseData.error, responseData.b);

                })


            }


            appApi.device.scanCode = function (callback) {

                bridge.callHandler('resignScanCodeAction', function (responseData) {

                    callback(responseData.data,responseData.error);

                })


            }


            appApi.ui.navigation.onRollbackButtonClick = function (callback) {


                bridge.registerHandler('TheBackButtonHaveClick', function () {


                    callback();

                })
                bridge.callHandler('didJSResignSuccessed', function (responseData) {

                });


            }


            appApi.map.selectMark = function (id, callback) {


                bridge.callHandler('ocjs_letThePointsHightLight', id, function (responseData) {


                    callback(responseData.error, responseData.b);

                })


            }


            appApi.map.selectLine = function (id, callback) {


                bridge.callHandler('ocjs_letTheLinesHightLight', id, function (responseData) {


                    callback(responseData.error, responseData.b);

                })


            }


            appApi.map.getMapMark = function (callback) {


                bridge.callHandler('ocjs_giveBackPointsToJS', function (responseData) {


                    callback(responseData.error, responseData.data);

                })


            }

            //getMapLine
            appApi.map.getMapLine = function (callback) {


                bridge.callHandler('ocjs_giveBacklinesToJS', function (responseData) {


                    callback(responseData.error, responseData.data);

                })


            }


            appApi.onStatusBar = function (callback) {


                bridge.registerHandler('WhenTheStateBarTouch', function (data, responseCallback) {

                    callback();

                })


            }


            //��ӹرհ�ť
            appApi.ui.navigation.addCloseButton = function (isHidden, callback) {

                bridge.callHandler('addCloseButton', isHidden, function (responseData) {


                    callback();

                })


            }

            //��ȡtoken
            appApi.getToken = function (callback) {


                bridge.callHandler('GetTheUserToken', function (responseData) {


                    callback(responseData);

                })


            }
            appApi.pushToNewWebview = function (url, callback) {


                bridge.callHandler('ocjs_pushToNewWebview', url, function (responseData) {


                    callback();

                })


            }
            appApi.tosatAtIphone = function (title, callback) {


                bridge.callHandler('ocjs_toastatnative', title, function (responseData) {

                    callback();

                })

            }


            appApi.cancelCollectPOI = function (mapSiteData, callback) {

                bridge.callHandler('ocjs_cancelCollect', mapSiteData, function (responseData) {


                    callback(responseData);

                });

            }

            //�ղ��豸����poi��
            appApi.collectPOI = function (mapSiteData, callback) {

                bridge.callHandler('CollectTheEquiment', mapSiteData, function (responseData) {

                    callback(responseData);

                })


            }
            setTimeout(function(){
                appApi.onLoaded();
            },1)



        };
        setupWebViewJavascriptBridge(zwiosobj);
    }
    //��׿
    else if (/android/.test(ua)) {
        (function () {
            if (window.WebViewJavascriptBridge) {
                return;
            }
            var messagingIframe;
            var sendMessageQueue = [];
            var receiveMessageQueue = [];
            var messageHandlers = {};

            var CUSTOM_PROTOCOL_SCHEME = 'yy';
            var QUEUE_HAS_MESSAGE = '__QUEUE_MESSAGE__/';

            var responseCallbacks = {};
            var uniqueId = 1;

            function _createQueueReadyIframe(doc) {
                messagingIframe = doc.createElement('iframe');
                messagingIframe.style.display = 'none';
                doc.documentElement.appendChild(messagingIframe);
            }

            // set default messageHandler
            function init(messageHandler) {
                if (WebViewJavascriptBridge._messageHandler) {
                    throw new Error(
                        'WebViewJavascriptBridge.init called twice');
                }
                WebViewJavascriptBridge._messageHandler = messageHandler;
                var receivedMessages = receiveMessageQueue;
                receiveMessageQueue = null;
                for (var i = 0; i < receivedMessages.length; i++) {
                    _dispatchMessageFromNative(receivedMessages[i]);
                }
            }

            function send(data, responseCallback) {
                _doSend({
                    data: data
                }, responseCallback);
            }

            function registerHandler(handlerName, handler) {
                messageHandlers[handlerName] = handler;
            }

            function callHandler(handlerName, data, responseCallback) {
                _doSend({
                    handlerName: handlerName,
                    data: data
                }, responseCallback);
            }

            // sendMessage add message, 触发native处理 sendMessage
            function _doSend(message, responseCallback) {
                if (responseCallback) {
                    var callbackId = 'cb_' + (uniqueId++) + '_'
                        + new Date().getTime();
                    responseCallbacks[callbackId] = responseCallback;
                    message.callbackId = callbackId;
                }

                sendMessageQueue.push(message);
                messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://'
                    + QUEUE_HAS_MESSAGE;
            }

            // 提供给native调用,该函数作用:获取sendMessageQueue返回给native,由于android不能直接获取返回的内容,所以使用url
            // shouldOverrideUrlLoading 的方式返回内容
            function _fetchQueue() {
                var messageQueueString = JSON
                    .stringify(sendMessageQueue);
                sendMessageQueue = [];
                // android can't read directly the return data, so we
                // can reload iframe
                // src to communicate with java
                messagingIframe.src = CUSTOM_PROTOCOL_SCHEME
                    + '://return/_fetchQueue/'
                    + encodeURIComponent(messageQueueString);
            }

            // 提供给native使用,
            function _dispatchMessageFromNative(messageJSON) {
                setTimeout(function () {
                    var message = JSON.parse(messageJSON);
                    var responseCallback;
                    // java call finished, now need to call js callback
                    // function
                    if (message.responseId) {
                        responseCallback = responseCallbacks[message.responseId];
                        if (!responseCallback) {
                            return;
                        }
                        responseCallback(message.responseData);
                        // delete responseCallbacks[message.responseId];
                    } else {
                        // 直接发送
                        if (message.callbackId) {
                            var callbackResponseId = message.callbackId;
                            responseCallback = function (responseData) {
                                _doSend({
                                    responseId: callbackResponseId,
                                    responseData: responseData
                                });
                            };
                        }

                        var handler = WebViewJavascriptBridge._messageHandler;
                        if (message.handlerName) {
                            handler = messageHandlers[message.handlerName];
                        }
                        // 查找指定handler
                        try {
                            handler(message.data, responseCallback);
                        } catch (exception) {
                            if (typeof console != 'undefined') {
                                console
                                    .log(
                                        "WebViewJavascriptBridge: WARNING: javascript handler threw.",
                                        message, exception);
                            }
                        }
                    }
                });
            }

            // 提供给native调用,receiveMessageQueue 在会在页面加载完后赋值为null,所以
            function _handleMessageFromNative(messageJSON) {
                console.log(messageJSON);
                if (receiveMessageQueue) {
                    receiveMessageQueue.push(messageJSON);
                } else {
                    _dispatchMessageFromNative(messageJSON);
                }
            }

            var WebViewJavascriptBridge = window.WebViewJavascriptBridge = {
                init: init,
                send: send,
                registerHandler: registerHandler,
                callHandler: callHandler,
                _fetchQueue: _fetchQueue,
                _handleMessageFromNative: _handleMessageFromNative
            };

            var doc = document;
            _createQueueReadyIframe(doc);
            var readyEvent = doc.createEvent('Events');
            readyEvent.initEvent('WebViewJavascriptBridgeReady');
            readyEvent.bridge = WebViewJavascriptBridge;
            doc.dispatchEvent(readyEvent);
            function bridgeLog(logContent) {
                // document.getElementById("show").innerHTML =
                // logContent;
            }

            function connectWebViewJavascriptBridge(callback) {
                if (window.WebViewJavascriptBridge) {
                    callback(WebViewJavascriptBridge)
                } else {
                    document.addEventListener(
                        'WebViewJavascriptBridgeReady', function () {
                            callback(WebViewJavascriptBridge)
                        }, false);
                }
            }

            connectWebViewJavascriptBridge(function (bridge) {
                bridge.init(function (message, responseCallback) {
                    console.log('JS got a message', message);
                    var data = {
                        'Javascript Responds': '测试中文!'
                    };
                    console.log('JS responding with', data);
                    responseCallback(data);
                });

                bridge
                    .registerHandler(
                        "functionInJs",
                        function (data, responseCallback) {
                            var responseData = "Javascript Says Right back aka!";
                            responseCallback(responseData);
                        });

            })
        })();

// ///////////////////////////////////////////////////////////////
        //lyy掉高德地图(设备导航)-----
        appApi.deviceNav= function(geometry,callback){
            window.WebViewJavascriptBridge.callHandler('SetTheGeometry',geometry,function(responseData){
                callback(responseData);
            });
        }
        //--------
        appApi.ui.navigation.setTitle = function (title, callback) {
            window.WebViewJavascriptBridge.callHandler('TheNavBarTitleChange', {
                "title": title
            }, function (responseData) {
                callback(responseData);
            })
        }
        appApi.ui.navigation.setColor = function (color, callback) {
            window.WebViewJavascriptBridge.callHandler('TheNavBarColorChange', {
                "color": color
            }, function (responseData) {
                callback(responseData);
            })
        }

        appApi.ui.navigation.setMenu = function (parameters, callback) {
            window.WebViewJavascriptBridge.callHandler('TheNavBarRightButtonSet', {
                'menuStyle': parameters
            }, function (responseData) {
                for (var i = 0; i < parameters.items.length; i++) {
                    if (parameters.items[i].type == responseData) {
                        parameters.items[i].onClick();
                    }
                }
                callback(responseData);
            })
        }

        appApi.device.getNetworkType = function (callback) {
            window.WebViewJavascriptBridge.callHandler('getTheAppNetType', {
                "": ""
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata);
            })
        }

// 唤起聊天页面
        appApi.showIm = function (userID, callback) {
            window.WebViewJavascriptBridge
                .callHandler(
                    'EnterTheChatVC',
                    {
                        "userId": userID
                    },
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    })
        };

        appApi.showUserInfo = function (userID, callback) {
            window.WebViewJavascriptBridge.callHandler('EnterTheUserInformationVC', {
                "userId": userID
            }, function (responseData) {
                callback(responseData);
            })
        };

// 发送信息
        appApi.sendMessage = function (targets, isGroupTaraget, msg, callback) {
            window.WebViewJavascriptBridge
                .callHandler(
                    'sendMessageAction', msg,
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    })
        }

        appApi.choosUsers = function (parameters, callback) {
            window.WebViewJavascriptBridge.callHandler('ModelTheCommonUser', {
                'startWithDepartmentId': parameters.startWithDepartmentId,
                'multiple': parameters.multiple,
                'onlyUser': parameters.onlyUser
            }, function (responseData) {
                var data = JSON.parse(responseData);
                callback(data);
            })
        }

// 获取本机图片
        appApi.device.getImage = function (callback) {
            window.WebViewJavascriptBridge.callHandler('getThePhotoFromPhone', {
                '': ''
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.data, responsedata.type);
            })

        };

        appApi.getLocation = function (targetAccuracy, callback) {

            window.WebViewJavascriptBridge.callHandler('GetThePresentLocaltion', {
                "targetAccuracy": targetAccuracy
            }, function (responseData) {
                var location = JSON.parse(responseData);
                callback(location);
            });
        };

        appApi.showMap = function (url, type, height, callback,backData) {
            window.WebViewJavascriptBridge.callHandler('EnterTheAddMarkVCWithType', {
                'url': url,
                'type': type,
                'height': height
            }, function (responseData) {
                callback(responseData);
            });

            window.WebViewJavascriptBridge.callHandler('EnterTheAddMarkVCWithTypeBackData', {
                'url': url,
                'type': type,
                'height': height
            }, function (responseData) {
                backData(responseData);
            });

        };

        appApi.device.audio.startRecord = function (callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'startRecordTheAudio',
                    function (responseData) {
                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        };

        appApi.device.audio.stopRecord = function (callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'stopRecordAudio',
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        }

        appApi.device.audio.onRecordEnd = function (callback) { // oc主动调用js

            window.WebViewJavascriptBridge.registerHandler("whenTheRecordAudioStoped",
                function (data, responseCallback) {
                    responseCallback()
                });
        }

        appApi.device.audio.getRecord = function (audioID, callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'getTheAudioFromTheOCApp',
                    audioID,
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        }

        appApi.device.audio.play = function (audioID, callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'playTheAudio',
                    audioID,
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        }

        appApi.device.audio.pause = function (audioID, callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'pauseTheAudio',
                    audioID,
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });

        }

        appApi.device.audio.resume = function (audioID, callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'resumeTheAudio',
                    audioID,
                    function (responseData) {

                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        }

        appApi.device.audio.stop = function (audioID, callback) {

            window.WebViewJavascriptBridge
                .callHandler(
                    'stopPlayTheAudio',
                    audioID,
                    function (responseData) {
                        callback(responseData);
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });

        }

        appApi.device.audio.onPlayEnd = function (callback) {

            window.WebViewJavascriptBridge
                .registerHandler(
                    "whenTheRecordAudioStoped",
                    function (data, responseCallback) {
                        responseCallback();
                        log(
                            "JS call ObjC's getUserIdFromObjC function, and js received response:",
                            responseData)
                    });
        }

// // 唤起路径搜索界面
        appApi.showNavigation = function (data, callback) {

            window.WebViewJavascriptBridge.callHandler("showPathProgramme", data, function (responseData) {
                callback(responseData);
            });
        }

// 地图 marker 单击事件
        appApi.map.onMapTapEvent = function (callback) {

            window.WebViewJavascriptBridge.registerHandler('whenUserTapTheMap',
                function (response, responseCallback) {
                    var data = JSON.parse(response);
                    callback(data.error, data.data);

                })

        }

// 地图添加标注点
        appApi.map.addMark = function (data, callback) {
            window.WebViewJavascriptBridge.callHandler('AddMarkToTheMap', {
                'data': data
            }, function (responseData) {
                var res = JSON.parse(responseData);
                callback(res.error, res.b);
            })
        }
// 地图选位置
        appApi.map.mapSiteSelection = function (callback) {

            window.WebViewJavascriptBridge.callHandler('selectFromTheMap', function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata);

            })

        }

// 扫描二维码
        appApi.device.scanCode = function (Callback) {
            window.WebViewJavascriptBridge.callHandler('resignScanCodeAction', {
                '': ''
            }, function (responseData) {
                var data = JSON.parse(responseData);
                callback(data);
            })
        }

// 向手机端传index 当前点
        appApi.map.selectMark = function (index, callback) {

            window.WebViewJavascriptBridge.callHandler('letThefirstPointHight', {
                "index": index
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);
            })
        }

// 获取地图上的点
        appApi.map.getMapMark = function (callback) {

            window.WebViewJavascriptBridge.callHandler('giveBackTheIocnToJS', {
                'index': '1'
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.data);

            })

        }

// 状态栏点击
        appApi.onStatusBar = function (callback) {
            window.WebViewJavascriptBridge.registerHandler('WhenTheStateBarTouch',
                function (data, responseCallback) {
                    callback();
                })

        }

// 添加关闭按钮
        appApi.ui.navigation.addCloseButton = function (isHidden, callback) {
            window.WebViewJavascriptBridge.callHandler('addCloseButton', {
                'isHidden': isHidden
            }, function (responseData) {
                callback(responseData);
            });
        }

// 获取token
        appApi.getToken = function (callback) {
            window.WebViewJavascriptBridge.callHandler('getToken', {
                'param': '中文测试'
            }, function (responseData) {
                var userInfo = JSON.parse(responseData);
                callback(userInfo);
            });
        }

        appApi.ui.navigation.close = function (data,callback) {
            window.WebViewJavascriptBridge.callHandler('CloseTheNavBarAction', {
                'param': data
            }, function (responseData) {
                callback(responseData);
            });

        }

        appApi.ui.navigation.onRollbackButtonClick = function (callback) {
            window.WebViewJavascriptBridge.registerHandler('TheBackButtonHaveClick', function (response, responseCallback) {
                callback();
            });
        }

        appApi.collectPOI = function (mapSiteData, callback) {
            window.WebViewJavascriptBridge.callHandler('TheCollectionClicked', {
                'mapSiteData': mapSiteData
            }, function (responsedata) {
                callback(responsedata);
            });
        }

        appApi.alterAndSendMessage = function (msg, callback) {

            window.WebViewJavascriptBridge.callHandler('alterAndSendMessage', {"msg": msg}, function (responseData) {
                callback(responseData);
            })

        }
        appApi.tosatAtIphone = function (title, callback) {


            window.WebViewJavascriptBridge.callHandler('toastatnative', {"title": title}, function (responseData) {
                callback();
            })

        }

        appApi.cancelCollectPOI = function (mapSiteData, callback) {

            window.WebViewJavascriptBridge.callHandler('cancelCollect', {
                "mapSiteData": mapSiteData
            }, function (responseData) {
                callback(responseData);
            });

        },

// getMapLine
            appApi.map.getMapLine = function (callback) {
                window.WebViewJavascriptBridge.callHandler('giveBacklinesToJS', {
                    '': ''
                }, function (responseData) {
                    var responsedata = JSON.parse(responseData);
                    callback(responsedata.error, responsedata.data);
                });
            }

// addLine
        appApi.map.addLine = function (data, callback) {

            window.WebViewJavascriptBridge.callHandler('addLinesToTheMap', {'data': data},
                function (responseData) {
                    var responsedata = JSON.parse(responseData);
                    callback(responsedata.error, responsedata.b);

                });
        }
//
        appApi.map.removeSelectMark = function (id, callback) {

            window.WebViewJavascriptBridge.callHandler('removeSelectMark', {
                'id': id
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);

            });
        }
        appApi.map.selectLine = function (id, callback) {

            window.WebViewJavascriptBridge.callHandler('letTheLinesHightLight', {
                'id': id
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);

            });
        }
        appApi.map.removeSelectLine = function (id, callback) {

            window.WebViewJavascriptBridge.callHandler('removeSelectLine', {
                'id': id
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);
            });
        }
        appApi.map.removeAllMark = function (callback) {
            window.WebViewJavascriptBridge.callHandler('removeAllMark', function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);

            });
        }

// removeAllLine
        appApi.map.removeAllLine = function (callback) {
            window.WebViewJavascriptBridge.callHandler('removeAlllines', {
                '': ''
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);

            });
        }

        appApi.map.removeIdsMark = function (ids, callback) {
            window.WebViewJavascriptBridge.callHandler('removeIdsMark', {
                'ids': ids
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);
            });
        }

// removeIdsLine
        appApi.map.removeIdsLine = function (ids, callback) {
            window.WebViewJavascriptBridge.callHandler('removeIdsline', {
                'ids': ids
            }, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.b);
            });
        }

        // 可视区域内定位
        appApi.map.visualAreaLocation = function (maxLongitude, maxLatitude,
                                                  minLongitude, minLatitude) {
            var param = {
                'maxLong': maxLongitude,
                'maxLat': maxLatitude,
                'minLong': minLongitude,
                'minLat': minLatitude
            };
            window.WebViewJavascriptBridge.callHandler('visualAreaLocation', {
                'maxLong': maxLongitude,
                'maxLat': maxLatitude,
                'minLong': minLongitude,
                'minLat': minLatitude
            }, function (responseData) {
            });
        }

        //拖动偏移量窗
        appApi.map.noticeChangeOffset = function(callback){

            window.WebViewJavascriptBridge.registerHandler('noticeChangeOffset',function(data, responseCallback){

                callback(data)

            })


        }
        //改变工具条状态
        appApi.map.changeToolBarState = function(title,callback){

            window.WebViewJavascriptBridge.callHandler('changeToolBarState',{'title':title},function(responseData){
                callback(responseData);
            })
        }
        //音频
        appApi.device.alterAudioRecorder = function (data,callback) {
            window.WebViewJavascriptBridge.callHandler('alterAudioRecorder', {'data': data}, function (responseData) {
                var responsedata = JSON.parse(responseData);
                callback(responsedata.error, responsedata.data, responsedata.time, responsedata.audioSize);

            });
        }

        appApi.map.addBubble = function (type, data, callback) {
            window.WebViewJavascriptBridge.callHandler('addBubbleView', {
                'type': type,
                'data': data
            }, function (responseData) {
                var response = JSON.parse(responseData);
                callback(response.b, response.error);
            })

        }

        appApi.map.removeAllBubble = function (callback) {

            window.WebViewJavascriptBridge.callHandler('removeAllBubble', {'': ''}, function (responseData) {
                var response = JSON.parse(responseData);
                callback(response.b, response.error);
            })
        }

        appApi.map.removeSelectBubble = function (id, callback) {

            window.WebViewJavascriptBridge.callHandler('removeSelectBubble', {'id': id}, function (responseData) {
                var response = JSON.parse(responseData);
                callback(response.error, response.b);
            })

        }

        appApi.map.giveWebviewHeight = function (height, callback) {

            window.WebViewJavascriptBridge.callHandler('AMDCtrlOffsetHeight', {'height': height}, function (responseData) {
                var response = JSON.parse(responseData);
                callback(response.error, response.b);
            })
        }
        setTimeout(function () {
            appApi.onLoaded();
        }, 1);
    }
    return appApi;
})();